package payroll.trans;


import payroll.Employee;
import payroll.PayrollDatabase;
import payroll.Transaction;
import payroll.exception.NoSuchEmployeeException;

public class DeleteEmployeeTransaction implements Transaction{
    private int id;
    public DeleteEmployeeTransaction(int id) {
        this.id = id;
    }



    @Override
    public void execute() {
        Employee e = PayrollDatabase.getEmployee(id);
        if (e != null) {
            PayrollDatabase.deleteEmployee(id);

        } else {
            throw new NoSuchEmployeeException();
        }
    }
}
